import React, { Component } from 'react';
import { connect } from 'react-redux'
import '../App.css';
import * as userAction from '../actions/userAction'
class App extends Component {
  render () {
    console.log('App:render---', this.props)
    let { isLogin, isLoading } = this.props.user
    return (
      <div className="App">
        <header className="App-header">
          <span>Redux-Test</span>
          <span>{isLogin ? '欢迎您' : '未登录'}</span>
          <span>{isLoading ? '正在加载中...' : ''}</span>
          <button onClick={() => this.props.dispatch(userAction.login({account: '王二麻子', psw: '123456'}))}>登录</button>
          {/* <NavLink to="/home">
            <button>跳转学生页面</button>
          </NavLink> */}
          <button onClick={() => this.props.history.push('/home')}>跳转学生页面</button>
        </header>
      </div>
    )
  }
}

export default connect(state => {
  return {
    user: state.userReducer
  }
})(App)
